package com.hospital.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.domain.Department;
import com.hospital.domain.Doctor;
import com.hospital.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao extends BaseMapper<User> {
//    @Select("select * from userinfo")
    List<User> selectAll();

    @Select("select * from doctorinfo")
    List<Doctor> selectAllDoctor(@Param("doctorName") String doctorName,@Param("departmentID") int departmentID);

    @Select("select * from userinfo where accountNum = #{accountNum} and pwd = #{pwd}")
    User login(@Param("accountNum") String accountNum, @Param("pwd") String pwd);


    @Select("select * from userinfo where userID = #{userID}")
    User selectUser(int UserID);

    @Select("select * from departmentinfo")
    List<Department> selectAllDep();

    @Select("select * from userinfo where accountNum = #{accountNum}")
    User selectByAccount(@Param("accountNum") String accountNum);

    @Insert("insert into userinfo values (null,#{userName},#{pwd},#{accountNum},#{sex},#{age},#{IDcard},#{phoneNum})")
    int addUser(User user);

    @Update("update userinfo set userName=#{userName},pwd=#{pwd},accountNum=#{accountNum},sex=#{sex},age=#{age},IDcard=#{IDcard},phoneNum=#{phoneNum} " +
            "where userID = #{userID}")
    int updateUser(User user);

    @Select("select * from userinfo where accountNum = #{accountNum}")
    User selectUserByAccount(String accountNum);
}
